﻿@{
    Layout = null;
}

<html class="x-admin-sm">
<head>
    <meta name="viewport" content="width=device-width" />
    <meta charset="UTF-8">
    <title>工序选择</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/Content/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/Content/X-admin/lib/layui/layui.js"></script>
    <link href="~/Content/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/Content/X-admin/js/jquery.min.js"></script>
    <script src="~/Content/X-admin/js/xadmin.js"></script>
    <script src="~/Content/Scripts/System/systemFrame.js"></script>
    <script src="~/Content/Scripts/System/Common.js"></script>
</head>
<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn" lay-filter="sreach" id="btnSure" type="button" onclick="sureChoose()"><i class="layui-icon">&#xe679;</i>确认</button>
                        </div>

                    </div>
                    <div class="layui-card-body layui-table-body layui-table-main">
                        <table class="layui-hide" id="list" lay-filter="list"></table>
                        <input type="hidden" name="svalue" id="svalue" />
                        <input type="hidden" name="sname" id="sname" />
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
    var single = "1";
    var sCodes = "";
    $(function () {
        single = getUrlVariable("isSingle");
        sCodes = getUrlVariable("pStr");
        loadData();
    });
    function loadData() {
        layui.use('table', function () {
            var table = layui.table;
            table.render({
                elem: '#list'
            , url: "../Common/GetDataList?dataType=csl&condition=" + sCodes
            , skin: 'row' //表格风格
            , even: true
            , page: false //是否显示分页
            , cols: [[ //标题栏
               { type: 'checkbox' }
             , { field: 'code', title: '状态编码', width: 120 }
             , { field: 'name', title: '状态名称', width: 150 } //空列

            ]]

            });
            //监听工具条
            table.on('checkbox(list)', function (obj) {
                var data = obj.data;
                //为父窗口input赋值
                $("#svalue").val("");
                var checkStatus = table.checkStatus('list');
                var codes = "", names = "";
                for (var i = 0; i < checkStatus.data.length; i++) {
                    codes += checkStatus.data[i].code + ",";
                    names += checkStatus.data[i].name + ",";
                }
                $("#svalue").val(codes.substr(0, codes.length - 1));
                $("#sname").val(names.substr(0, names.length - 1));
            });

        });
    }
    function sureChoose() {
        var value = $("#svalue").val();
        var sname = $("#sname").val();

        if (value == "") {
            layer.msg("没有选择任何数据"); return;
        } else {
            if (single == "1") {
                if (value.indexOf(",") >= 0) {
                    layer.msg("请选择一条数据记录"); return;
                }
            }
            parent.$('#pStatusCode').val(value);
            parent.$('#pStatusName').val(sname);
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭
        }

    }
</script>
